const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    statusBarHeight: '74',
      swiperData:{
        background:[
          '//cdn.cnbj1.fds.api.mi-img.com/mi-mall/b702ae58d580077790fd21932d664f18.jpg?thumb=1&w=720&h=360',
          '//cdn.cnbj1.fds.api.mi-img.com/mi-mall/39f81c39ff29edcf58b1a38a11dbfd96.jpg?thumb=1&w=720&h=360',
          '//cdn.cnbj1.fds.api.mi-img.com/mi-mall/4c4be1982605371abde9a21c1b03d489.jpg?thumb=1&w=720&h=360'
        ],
        indicatorDots: true,
        indicatorColor: 'rgba(255,255,255, .5)',
        indicatorActiveColor: '#ff6700',
        autoplay: true,
        circular: true
      },
      explosion:{
        background:[
          '//cdn.cnbj1.fds.api.mi-img.com/mi-mall/cb65daec7ef7b52cc785f88f78efba37.png?thumb=1&w=144&h=152',
          '//i8.mifile.cn/v1/a1/eb5024fe-dfe3-6e53-3e18-675bef5fa06e.webp',
          '//cdn.cnbj1.fds.api.mi-img.com/mi-mall/d436f30612651fffe1d6c5aaa3fdb816.png?thumb=1&amp;w=144&amp;h=152',
          '//i8.mifile.cn/v1/a1/e8bc849a-0a3b-21a0-6810-7da3a3903dee.webp',
          '//i8.mifile.cn/v1/a1/7dbcbf87-6a58-adb6-2f3f-bb3dae3e9c80.webp',
          '//cdn.cnbj1.fds.api.mi-img.com/mi-mall/64f3988b6216e4c1ab62a7f50df3e816.png?thumb=1&w=144&h=152',
          '//cdn.cnbj1.fds.api.mi-img.com/mi-mall/9ea68dee2bfa0e55a82236b0d968e975.png?thumb=1&w=144&h=152',
          '//cdn.cnbj1.fds.api.mi-img.com/mi-mall/96c780016ea196743905dc93f9249c39.png?thumb=1&w=144&h=152',
          '//cdn.cnbj1.fds.api.mi-img.com/mi-mall/9425031cdd7af22d9a23a5ae16d1f57c.jpg?thumb=1&w=144&h=152',
          '//cdn.cnbj1.fds.api.mi-img.com/mi-mall/f11f9df6b0b0b428f8c8fc3267131830.png?thumb=1&w=144&h=152']
      },
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // console.log(app.globalData.statusBarHeight)
    this.setData({
      statusBarHeight: app.globalData.statusBarHeight + 8
    })
    const that = this;
    var commodity = [
      {
        titleImg:'//cdn.cnbj1.fds.api.mi-img.com/mi-mall/e32eea5c3c27062019f9ac6434b351df.jpg?thumb=1&w=720&h=440',
        commodityContent: [
          {
            itemImg:'//cdn.cnbj1.fds.api.mi-img.com/mi-mall/cf8c841ab5e52d443be110f6aa7e0d98.jpg?thumb=1&w=344&h=280',
            itemName:'小米10 Pro',
            itemOverview: '晓龙865 / 50倍变焦',
            itemPrice: '￥4999起'
          },{
            itemImg:'//cdn.cnbj1.fds.api.mi-img.com/mi-mall/cf8c841ab5e52d443be110f6aa7e0d98.jpg?thumb=1&w=344&h=280',
            itemName:'小米10 Pro',
            itemOverview: '晓龙865 / 50倍变焦',
            itemPrice: '￥4999起'
          },{
            itemImg:'//cdn.cnbj1.fds.api.mi-img.com/mi-mall/cf8c841ab5e52d443be110f6aa7e0d98.jpg?thumb=1&w=344&h=280',
            itemName:'小米10 Pro',
            itemOverview: '晓龙865 / 50倍变焦',
            itemPrice: '￥4999起'
          },{
            itemImg:'//cdn.cnbj1.fds.api.mi-img.com/mi-mall/cf8c841ab5e52d443be110f6aa7e0d98.jpg?thumb=1&w=344&h=280',
            itemName:'小米10 Pro',
            itemOverview: '晓龙865 / 50倍变焦',
            itemPrice: '￥4999起'
          }
        ],
        more:'更多小米手机 >'
      },{
        titleImg:'//cdn.cnbj1.fds.api.mi-img.com/mi-mall/e32eea5c3c27062019f9ac6434b351df.jpg?thumb=1&w=720&h=440',
        commodityContent: [
          {
            itemImg:'//cdn.cnbj1.fds.api.mi-img.com/mi-mall/cf8c841ab5e52d443be110f6aa7e0d98.jpg?thumb=1&w=344&h=280',
            itemName:'小米10 Pro',
            itemOverview: '晓龙865 / 50倍变焦',
            itemPrice: '￥4999起'
          },{
            itemImg:'//cdn.cnbj1.fds.api.mi-img.com/mi-mall/cf8c841ab5e52d443be110f6aa7e0d98.jpg?thumb=1&w=344&h=280',
            itemName:'小米10 Pro',
            itemOverview: '晓龙865 / 50倍变焦',
            itemPrice: '￥4999起'
          },{
            itemImg:'//cdn.cnbj1.fds.api.mi-img.com/mi-mall/cf8c841ab5e52d443be110f6aa7e0d98.jpg?thumb=1&w=344&h=280',
            itemName:'小米10 Pro',
            itemOverview: '晓龙865 / 50倍变焦',
            itemPrice: '￥4999起'
          },{
            itemImg:'//cdn.cnbj1.fds.api.mi-img.com/mi-mall/cf8c841ab5e52d443be110f6aa7e0d98.jpg?thumb=1&w=344&h=280',
            itemName:'小米10 Pro',
            itemOverview: '晓龙865 / 50倍变焦',
            itemPrice: '￥4999起'
          }
        ],
        more:'更多小米手机 >'
      }
    ]

    var subjectArray = []
    // 第一层循环
    for(var idx in commodity) {           
        var subject = commodity[idx]
        var temp = {
          commodityImg: subject.titleImg,
          commodityContentArray:subject.commodityContent,
          commodityMore: subject.more
        }
        subjectArray.push(temp)
    }    
    that.setData({
        commodityArray: subjectArray
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})